package com.lineage.server.serverpackets;

import com.lineage.server.model.L1Character;

public class S_HPMeter extends ServerBasePacket {
  private byte[] _byte;
  
  public S_HPMeter(int objId, int hpRatio) {
    this._byte = null;
    buildPacket(objId, hpRatio);
  }
  
  public S_HPMeter(L1Character cha) {
    this._byte = null;
    int objId = cha.getId();
    int hpRatio = 100;
    if (cha.getMaxHp() > 0)
      hpRatio = 100 * cha.getCurrentHp() / cha.getMaxHp(); 
    buildPacket(objId, hpRatio);
  }
  
  private void buildPacket(int objId, int hpRatio) {
    writeC(237);
    writeD(objId);
    writeC(hpRatio);
  }
  
  public byte[] getContent() {
    if (this._byte == null)
      this._byte = getBytes(); 
    return this._byte;
  }
  
  public String getType() {
    return getClass().getSimpleName();
  }
}
